package com.opgea.tutor.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.opgea.tutor.dao.AbstractDAO;
import com.opgea.tutor.dao.LocationDAO;
import com.opgea.tutor.domain.entities.Location;

@Repository
public class LocationDAOImpl extends AbstractDAO<Location> implements LocationDAO{

    @Autowired
    private SessionFactory sessionFactory;
    
    @Override
    public Location find(long id) {
	@SuppressWarnings("unchecked")
	List<Location> objects = sessionFactory.getCurrentSession()
		.createCriteria(Location.class).add(Restrictions.eq("id", id))
		.list();
	System.out.println(objects.get(0));
	return objects.get(0);
    }

}
